#ifndef READXLS_H
#define READXLS_H
#define DBUG 1

#include <QObject>
#include <QAxObject>
#include <QList>
#include <QDebug>
#include "XlsData.h"




class ReadXls;
class XlsSheet
{
public:
    XlsSheet(QAxObject *sheet)
    {
        Clear();
        if(0 == sheet)
            return;
        QAxObject *usedrange = sheet->querySubObject("UsedRange");
        if(0 == usedrange)
        {
            Clear();
            return;
        }
        QAxObject * rows = usedrange->querySubObject("Rows");
        if(0 == rows)
        {
            Clear();
            return;
        }
        QAxObject *columns = usedrange->querySubObject("Columns");
        if(0 == columns)
        {
            Clear();
            return;
        }

        mStartRow = usedrange->property("Row").toInt();
        mStartCol = usedrange->property("Column").toInt();
        mColCount = columns->property("Count").toInt();
        mRowCount = rows->property("Count").toInt();
    }
    virtual ~XlsSheet()
    {
    }
private:
    void Clear()
    {
        mStartRow = mStartCol = mRowCount = mColCount = 0;
    }
private:
    int mStartRow;
    int mStartCol;
    int mRowCount;
    int mColCount;

    friend class ReadXls;
};

class ReadXls : public QObject
{
    Q_OBJECT
public:
    ReadXls(QString xlsName, QObject *parent = 0);
    virtual ~ReadXls();

    int GetXlsSheetCount() const;

    int GetSheetUseColStart(int sheetIndex) const;
    int GetSheetUseColCount(int sheetIndex) const;
    int GetSheetUseRowStart(int sheetIndex) const;
    int GetSheetUseRowCount(int sheetIndex) const;

    QString GetData(int sheetIndex, int row, int col);
    bool StoreDataShown(DataTobeShown & dataTobeShwon, int sheetIndex,QString type = "rilei");
private:
    void Clear();
private:
    QList<XlsSheet> mListSheet;
    QAxObject *mXlsObj;
    QAxObject *mWorkBooks;
    QAxObject *mWorkBook;
    QAxObject *mSheets;
};

#endif // READXLS_H
